<?php
// +----------------------------------------------------------------------
// | Author: yaoyihong <510974211@qq.com>
// +----------------------------------------------------------------------

namespace app\api\logic;

use app\common\logic\LogicBase;
use \tpfcore\Core;
use think\Validate;

class AccountLog extends ApiBase
{
    public function getAccountLog($data = [])
    {

        $member_id = $this->getBaseUserInfo();
        
        $starttime = empty($data["starttime"])?"":strtotime($data["starttime"]);

        $endtime = empty($data["endtime"])?time():strtotime($data["endtime"]);

        $where = empty($data['type'])?['user_id'=>$member_id['id']]:['user_id'=>$member_id['id'],"type"=>$data['type']];
        
        if($starttime){
          $where['change_time'] = ['between',"$starttime,$endtime"];
        }else{
            $where['change_time']=["<=",$endtime];
        }
        $result = Core::loadModel($this->name)->getList([
            "where"=>$where,
            "paginate"  =>['rows' => DB_LIST_ROWS],
        ]);

        return [0,"success",$result];
    }
}